from sqlalchemy.orm import Session
from typing import List
from app.models.iaro_career.ite_survey_assigned import ITESurveyAssigned
from app.schema.survey_schema import ITESurveyCreate

def get_surveys_by_ite(db: Session, ite_id: int) -> List[ITESurveyAssigned]:
    return db.query(ITESurveyAssigned).filter(ITESurveyAssigned.ite_id == ite_id).all()

def assign_survey(db: Session, data: ITESurveyCreate) -> ITESurveyAssigned:
    record = ITESurveyAssigned(**data.dict())
    db.add(record)
    db.commit()
    db.refresh(record)
    return record